#include "appConfig.h"
#include <QString>

bool textCheck(QString & text,unsigned int val)
{
    bool ok;
    unsigned  int a = 0;
    int index  = text.indexOf("%");
    if(index > 0){
        return false;
    }
    if(index == 0){
        text = text.right(text.length() -1);
        a = text.toInt(&ok);
        if(ok ==false){
            text.clear();
            return false;
        }
        if(a > 100){
             text.clear();
            return false;
        }
        text = QString::number(a * val / 100);
        return true;
    }else{
        a = text.toInt(&ok);
        if(a > val)
            a = val;
         text = QString::number(a);
         return true;
    }
    return false;
}
